package com.itgaoshu.hospitalproject.mapper;

import com.itgaoshu.hospitalproject.bean.Lcheckup;
import com.itgaoshu.hospitalproject.bean.Register;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface LoutMapper{
    //查询已经出院的患者的信息
    List<Register> selRegisters(Register register);
    //查询该患者是否还有药品要取出才能出院
    @Select("select count(1) from hospitalprice where registerid=#{registerid} and state=0")
    int selYaos(Register register);

    //修改患者出院状态
    @Update("update register set state=1,endDate=now(),price=#{price} where registerid=#{registerid}")
    int updateR(Register register);
    //修改出院患者床位为空床
    @Update("update bed set state=0 where bedId=(select bedNum from register where registerid=#{registerid})")
    int updateB(Register register);

    //查询该患者出院之后的再一次的复查情况
    @Select("select c.cid,c.registerid,r.userName userName,c.content,c.ctime from checkup c ,register r where c.registerid=r.registerid and r.registerid=#{registerid}")
    List<Lcheckup> selCheckup(Register register);

}
